/* Background Info 

This master do file runs all of the code to reproduce all outputs for the paper 
'Dishonesty and Justifications: Evidence from the Second Roll of a Dice Game'
accepted for publication at the Journal of Behavioral and Experimental Economics. 

The work is joint with Ying-yi Hong (https://www.yingyihong.org/) 
I am Paul Clist, and my website is https://paulclist.github.io/ 

Experiment 2 was preregistered: see 
https://www.socialscienceregistry.org/trials/3547 

Data and code repository: 
https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/OXOGY3 

The structure of the folder is to have folders for code, data and outputs. 
If you a) download the folder, b) change the current directory below, and c) run the code
you should see all outputs in the output folder, newly created. 

Refer to the published paper for all numbering. 
*/

***** 	0. Preperation 
// a. change this file path to whether you've saved the dataset
version 18
clear all  


// EDIT THIS FILE PATH TO YOUR OWN FOLDER LOCATION
capture cd "C:\Users\ugx10yuu\OneDrive - University of East Anglia\work\datasets\jdb\replication\" 

// b. install any packages I use which you have not installed:

ssc install git //  so that you can install from github
 git install https://github.com/danbischof/plottig //  to install the great graph scheme by Daniel Bischof.

local ssc_packages texsave estout mgof qqvalue heatplot escftest palettes colrspace
foreach pkg of local ssc_packages {
    capture which `pkg'
    if _rc != 0 {
        display as result "Installing package: `pkg'"
        ssc install `pkg', replace
    }
}
*/


***** 	1. Others work, using ANR, section 2 / appendix 

do "code/figure 1.do" 
* note figure 1.do creates appendix table 1 too. (It is the same information in table form)
do "code/appendix figure 1.do" 


***** 	2. Calibration
do "code/table 1.do" 

***** 	3. Experiment 1
do "code/figure 2.do"
do "code/table 2.do"

***** 	4. Experiment 2
do "code/figure 4.do"
do "code/table 3.do"

***** 	5. Further Data, section 6
do "code/figure 5.do" 
do "code/table 4.do" 
do "code/table 5.do" 
do "code/figure 6.do"

*****  6. Extras
do "code/appendix table 2.do" 
do "code/appendix figure 3.do"  
do "code/appendix table 3.do" 
do "code/appendix table 4.do" 



exit
*****  7. optional extras

* this creates a latex file with the output, if you have the appropriate latex programs installed and findable
shell pdflatex check.tex

* this is just to clear the output and temp files which should be created by the do files. 
* mainly useful if you want to start again, so use carefully. 
local files : dir "output" files "*.*"
foreach file of local files {
    erase "output/`file'"
}

local files : dir "temp" files "*.*"
foreach file of local files {
    erase "temp/`file'"
}

* clears check non-latex files 

erase "check.aux"
erase "check.log"
erase "check.pdf"

* note - I used callsado to check which ado files I used. 
